<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTransferRecordsTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('transfer_records', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->bigInteger('agent_id')->index()->comment('代理ID');
            $table->bigInteger('asset_id')->index()->comment('资产ID');
            $table->bigInteger('to_user_id')->index()->comment('目标用户ID');
            $table->string('source')->comment('请求来源');
            $table->string('transfer_sn')->comment('请求流水号');
            $table->text('source_params')->comment('请求参数');
            $table->dateTime('transfer_time')->nullable()->comment('转移时间');
            $table->string('status', 16)->default(\App\Enums\TransferStatus::WAITING)->comment('资产转移状态');
            $table->text('remark')->nullable()->comment('备注信息');
            $table->index(['source', 'transfer_sn']);
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('transfer_records');
    }
}
